package com.hong.jarlauncher;

public class JarService {
    private String serviceName;
    private String jrePath;
    private String jarPath;
    private String jarName;
    private String arguments;

    // 构造函数、getter和setter方法
    public JarService() {}

    public JarService(String serviceName, String jrePath, String jarPath, String jarName, String arguments) {
        this.serviceName = serviceName;
        this.jrePath = jrePath;
        this.jarPath = jarPath;
        this.jarName = jarName;
        this.arguments = arguments;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getJrePath() {
        return jrePath;
    }

    public void setJrePath(String jrePath) {
        this.jrePath = jrePath;
    }

    public String getJarPath() {
        return jarPath;
    }

    public void setJarPath(String jarPath) {
        this.jarPath = jarPath;
    }

    public String getJarName() {
        return jarName;
    }

    public void setJarName(String jarName) {
        this.jarName = jarName;
    }

    public String getArguments() {
        return arguments;
    }

    public void setArguments(String arguments) {
        this.arguments = arguments;
    }

    public String generateCommand() {
        StringBuilder command = new StringBuilder();

        if (jrePath != null && !jrePath.isEmpty()) {
            command.append(jrePath).append("/bin/java");
        } else {
            command.append("java");
        }

        command.append(" -jar ");

        if (jarPath != null && !jarPath.isEmpty()) {
            command.append(jarPath).append("/");
        }

        command.append(jarName);

        if (arguments != null && !arguments.isEmpty()) {
            command.append(" ").append(arguments);
        }

        return command.toString();
    }
}